package ui;

import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.Toolkit;

import javax.swing.*;

public class UI extends JFrame {
	private static final long serialVersionUID = 8275217389198175167L;

	private static final Dimension
		screenSize = Toolkit.getDefaultToolkit().getScreenSize(),
		preferredSize = new Dimension(800,500);

	private static final JScrollPane
		main = new JScrollPane(),
		menu = new JScrollPane();
	/*private static final JScrollPane main = new JScrollPane();
	private static final Menu menu = new Menu();*/

	//private JMenuBar menuBar = new JMenuBar();

	public UI() throws HeadlessException {
		super("Kanji Learning Tool");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(false);
		this.setSize(preferredSize);

		//this.setJMenuBar(menuBar);

		// Move to center of screen.
		Point upperLeftCorner = new Point(
				Double.valueOf( // X
						screenSize.getWidth()/2 - preferredSize.getWidth()/2
					).intValue(),
				Double.valueOf( // Y
						screenSize.getHeight()/2 - preferredSize.getHeight()/2
					).intValue()
		);
		this.setLocation(upperLeftCorner.x, upperLeftCorner.y);

		main.setMinimumSize(new Dimension(500,500));
		menu.setMinimumSize(new Dimension(300,500));
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, main, menu);
		splitPane.setOneTouchExpandable(false);

		splitPane.setDividerLocation(500);
		splitPane.setDividerLocation(
			Double.valueOf(preferredSize.getWidth() - menu.getMinimumSize().getWidth()).intValue());

		splitPane.setPreferredSize(preferredSize);
		this.getContentPane().add(splitPane);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
				UI gui = new UI();
				gui.pack();
				gui.setVisible(true);
            }
		});
	}

}
